<template>
  <div>
    <Search @SearchBtn="SearchBtnFn">
      <template>
        <el-form-item>
          <template>
            <div class="text">{{ this.$route.meta.BtnText && this.$route.meta.BtnText.state }}</div>
            <el-input v-model="pageS.like_personName" placeholder="请输入" style="width: 228px;" />
          </template>
        </el-form-item>
      </template>
    </Search>
    <Table
      :table-data="tableData"
      :btn-text="'新增库区'"
      :pagecount="pagecount"
      @TypeChange="TypeChangeFn"
      @TopBtn="TopBtnFn"
      @CurrentChange="CurrentChangeFn"
      @SizeChange="SizeChangeFn"
      @OneBtn="OneBtnFn"
    />
  </div>
</template>

<script>
import { AllShipper } from '@/api'
export default {
  data() {
    return {
      tableData: [],
      CKtype: {},
      pageS: {
        size: 10,
        current: 1,
        descs: 'createTime'
      },
      pagecount: {}
    }
  },
  created() {
    this.AllShipperFn()
  },
  methods: {
    async AllShipperFn(Form) {
      const res = await AllShipper(this.pageS)
      console.log(res)
      this.pagecount = res.data.data
      res.data.data.records.forEach((item) => {
        const obj = {
          code: item.code,
          name: item.name,
          type: item.personName,
          location: item.phone,
          address: item.email,
          status: item.location,
          surface: item.address,
          includedNum: item.updateTime,
          id: item.id
        }
        this.tableData.push(obj)
      })
    },
    SearchBtnFn(Form) {
      console.log(Form)
      this.pageS.like_code = Form.innerCooder
      this.pageS.like_name = Form.name
      if (Form.state !== 2 && Form.state !== '') {
        this.pageS.status = Form.state
      }
      this.AllShipperFn()
      this.tableData = []
    },
    TypeChangeFn() { },
    TopBtnFn() {
      this.$router.push({
        path: '/manage-business/goods-owner/details'
      })
    },
    OneBtnFn(row) {
      console.log(row)
      this.$router.push({
        path: '/manage-business/goods-owner/details',
        query: {
          Id: row.id
        }
      })
    },
    // 页数跳转
    CurrentChangeFn(val) {
      this.pageS.current = val
      this.AllShipperFn()
      this.tableData = []
      console.log(val)
    },
    SizeChangeFn(val) {
      this.pageS.size = val
      this.AllShipperFn()
      this.tableData = []
    }
  }
}
</script>

<style>

</style>
